import { defineComponent, PropType } from "vue";

export default defineComponent({
  name: "LiTable",
  props: {
    data: {
      type: Array as PropType<any[]>,
      required: true
    },
    maxHeight: {
      type: Number as PropType<number>,
      required: true
    },
    columns: {
      type: Array as PropType<{ prop: string; label: string; sortable?: boolean; minWidth?: number }[]>,
      required: true
    },
    fixed: {
      type: Boolean as PropType<boolean>,
      default: true
    }
  },
  setup(props) {
    return () => (
      <el-table data={props.data} style="width: 100%" max-height={props.maxHeight}>
        {props.columns.map((item, index) => (
          <el-table-column
            fixed={props.fixed && index == 0 ? true : false}
            prop={item.prop}
            label={item.label}
            sortable={item.sortable ?? false}
            minWidth={item.minWidth ?? 120}
          />
        ))}
      </el-table>
    );
  }
});
